ReadLn

Syntax: @ReadLn filename, key_field_number, key_value, variable {, variable}

The ReadLn command reads information from an external file. Its main use is to use such files as external lookup tables. The filename can be a space or comma delimited ASCII format text file. If no path name is given, XpertRule will look for the file in the current data directory.

The file is searched by reading the file line by line until the specified data in key_field_number of the file matches the key_value. For example:

@ReadLn 'C:\wages\employee.txt', 2, 'Smith', Refnum, Name, Birthdate, Salary, Startdate

This would search down the 2nd field of the text file employee.txt, looking for an exact match to Smith. When found, the FIRST five fields of the line in the text file would be read into the five given variables. In this instance the name Smith is therefore one of the fields returned into Name. This can be avoided by using commas without needing to specify variables, e.g.

@ReadLn 'C:\wages\employee.txt', 2, 'Smith', , , Birthdate, Salary, Startdate

would skip returning the Refnum and Name fields.

It is the responsibility of the developer to trap situations where no match is found. This could be achieved by clearing the values of the variables being returned by the command, prior to the search. The variables could then be later tested for null values, to indicate an unsuccessful search.